package code;

import java.util.HashMap;
import java.util.Map;

public class Map1 {

	public static void main(String[] args) {
		String[] strings = { "a", "b", "a", "b","c"};
		 Map<String,Integer>map = new HashMap<String,Integer>();
		    String str="";
		    int count=1;
		  for(int i= 0; i<strings.length; i++){
		    if(map.containsKey(strings[i])){
		        count++;
		        map.put(strings[i],count);
		      }else{
		    	  map.put(strings[i],1);
		      }
		  }
		  for (Map.Entry<String, Integer> entry : map.entrySet()) {
			   System.out.println("key= " + entry.getKey() + " and value= " + entry.getValue());
			  }
	}		
}
